Electronic devices may contain optical sensors. For example, earbuds may contain optical proximity sensors based on infrared light-emitting diodes and infrared photodetectors. An optical proximity sensor may use an infrared light-emitting diode to emit infrared light. The emitted infrared light may reflect or backscatter off of an object in the vicinity of the proximity sensor. The strength of the reflected or backscattered light may be measured using an infrared photodetector to determine whether the object is near or far from the sensor. An earbud can use a proximity sensor to gather information on the operating state of the earbud such as whether the earbud has been inserted into the ear of a user.
Challenges can arise in gathering operating state information with an optical proximity sensor. For example, the intensity of emitted infrared light that is reflected or backscattered from a nearby object can be affected by the reflectivity and bidirectional reflectance distribution function (BRDF) of the object, which can lead to measurement inaccuracies.